package at.fhooe.pandora.physics;

import at.fhooe.engine.physics.forces.Force;

public class SpaceWindForce extends Force {

	private double m_xDir;
	private double m_yDir;
	private double m_acceleration;
	private double m_time;
	
	public SpaceWindForce(double acceleration) {
		m_acceleration = acceleration;
		m_time = 0;
		calculateRandomDirections();
	}
	
	
	
	private void calculateRandomDirections() {
		
		m_xDir = 10 * Math.random() - 5;
		m_yDir = 10 * Math.random() - 5;
		
		double length = Math.sqrt(m_xDir * m_xDir + m_yDir * m_yDir);
		m_xDir /= length;
		m_yDir /= length;
	}

	public double getAccelerationX(double time, double position,
			double velocity, double angularPosition) {
		m_time += time;
		//TODO Just a quick hack because it depends on the amount of Asteroids Entities!
		if(m_time > 400) {
			System.out.println("Space Wind is changing!");
			calculateRandomDirections();
			m_time = 0;
		}
		
		return m_acceleration * m_xDir;
	}

	public double getAccelerationY(double time, double position,
			double velocity, double angularPosition) {
		return m_acceleration * m_yDir;
	}

	public double getAngularAcceleration(double time, double position, double velocity, double angularPosition) {
		return 0;
	}
}
